/******************************************************************
 *
 *    tenant, Powered By uyun.cn.
 *
 *    Copyright (c) 2001-2020
 *    https://uyun.cn
 *
 *    Package:     wzg.com.pipe
 *
 *    Filename:    ReadData
 *
 *    Description: (用一句话描述该文件做什么)
 *
 *    Copyright:   Copyright (c) 2001-2020
 *
 *    Company:     uyun.cn
 *
 *    @author: 王志刚
 *
 *    @version: 1.0.0
 *
 *    Create at:   2018-01-05 下午5:19
 *
 *    Revision:
 *
 *    2018-01-05 下午5:19
 *        - first revision
 *
 *****************************************************************/
package wzg.com.pipe;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

/**
 * ReadData(这里用一句话描述这个类的作用)
 *
 * @author wangzg
 * @version 1.0.0
 * @create 2018-01-05 下午5:19
 */
public class ReadData {
    public void readMethod(PipedInputStream in){

        try {
            System.out.println("Read:");
            byte[] byteArray = new byte[20];
            int readLen = in.read(byteArray);
            while (readLen != -1) {
                String newData = new String(byteArray, 0, readLen);
                System.out.print(newData);
                readLen = in.read(byteArray);
            }
            System.out.println();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
